import React from 'react';
import FileUpload from './react-fileupload.jsx';

class FileUploader extends React.Component{
	render(){
		/*set properties*/
		const options={
			baseUrl			: '/manage/product/upload.do',
			fileFieldName	: 'upload_file',
			chooseAndUpload	: true,
			accept: 'image/*',
			uploadSuccess	: res =>{
				this.props.onSuccess(res.data);
			},
			uploadError		: err =>{
				this.props.onError(err.message);
			}
		}
		
		return (
			<FileUpload options={options}>
				<button ref="chooseAndUpload">上传图片</button>
			</FileUpload>
		)	        
	}
}

export default FileUploader;